package com.example.myapplication.viewmodelsharedcommondata.vd2;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import androidx.lifecycle.Observer;

import com.example.myapplication.R;

public class MainActity2 extends BaseActivity {

    TextView textView0;
    int munber = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_2);

        textView0 = findViewById(R.id.tv_textview_0);

        findViewById(R.id.tv_textview_1).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
               munber ++;

                projectViewModel.getIsActive().setValue("你点我呀" + munber);
            }
        });

        findViewById(R.id.tv_textview_2).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                projectViewModel.getIsActive().setValue("哈哈品保");
            }
        });

        findViewById(R.id.tv_textview_3).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MainActity2.this,MainActity3.class);
                startActivity(intent);
            }
        });






        projectViewModel.getIsActive().observe(this, new Observer<String>() {
            @Override
            public void onChanged(String aBoolean) {
                textView0.setText(aBoolean);
            }
        });
    }

}
